package arm.dic.bean;

import arm.dic.entity.DicOrganization;
import arm.common.manager.TableManager;
import arm.db.tools.DBManager;

public class DicOrganizationBean
{
    private DicOrganization organization;
    private TableManager<DicOrganization> tableManager;

    public DicOrganization getOrganization() {
        return organization;
    }

    public void setOrganization(DicOrganization organization) {
        this.organization = organization;
    }

    public String create()
    {
        organization = new DicOrganization();
        return "editDicOrganization";
    }


    public String save()
    {
        DBManager.saveOrUpdate(getOrganization());
        return viewTable();
    }

    public String edit()
    {
        setOrganization(getTableManager().getSelectedObj());
        return "editDicOrganization";
    }

    public String cancel()
    {
        return viewTable();
    }

    public String viewTable ()
    {
        getTableManager().readFromDB();
        return "viewDicOrganizationTable" ;
    }

    public TableManager<DicOrganization> getTableManager() {
        if (tableManager == null)
        {
            tableManager = new TableManager<DicOrganization>(DicOrganization.class);
        }
        return tableManager;
    }

    public void setTableManager(TableManager<DicOrganization> tableManager) {
        this.tableManager = tableManager;
    }

    public void delete ()
    {
        DBManager.delete(getTableManager().getSelectedObj());
        getTableManager().readFromDB();
    }


}


